import request from '@/utils/request'

// 面试题相关接口

// 获取面试题列表
export const getInterviewList = (params: any) => {
  return request.get(
    '/interviews',
    params
  )
}

// 获取面试题详情
export const getInterviewDetail = (id: number) => {
  return request.get(
    `/interviews/${id}`,
  )
}

// 获取面试题答案
export const getInterviewAnswer = (id: number) => {
  return request.get(
    `/interviews/${id}/answer`,
  )
}

// 点赞面试题
export const likeInterview = (id: number) => {
  return request.post(
    `/like/interview/${id}`,
  )
}

// 收藏面试题
export const favoriteInterview = (id: number) => {
  return request.post(
    `/favorite/interview/${id}`,
  )
}

// 搜索面试题
export const searchInterviews = (params: {
  keyword: string
  page?: number
  pageSize?: number
  categoryId?: number
  difficulty?: number
}) => {
  return request.get(
    '/interviews/search',
    params
  )
}

// 面试题类型定义
export interface Interview {
  id: number
  title: string
  question: string
  answer?: string
  difficulty: number
  categoryId: number
  requirePremium: boolean
  isLiked: boolean
  isFavorited: boolean
  likeCount: number
  favoriteCount: number
  viewCount: number
  createTime: string
  updatedTime: string
  previousId?: number | null
  nextId?: number | null
}